package com.rockxin.cat.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.orhanobut.logger.Logger;
import com.rockxin.cat.R;
import com.rockxin.cat.adapter.RunReportAdapter;
import com.rockxin.cat.base.BaseActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 运营报告
 */

public class RunReportActivity extends BaseActivity implements BaseQuickAdapter.OnItemClickListener {

    @BindView(R.id.back_img)
    ImageView backImg;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    private RunReportActivity mRunReportActivity;
    private RunReportAdapter mRunReportAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mRunReportActivity = this;
    }

    @Override
    protected int setLayout() {
        return R.layout.activity_run_report;
    }

    @Override
    public void initData() {
        title.setText("月度运营报告");
        recyclerView.setLayoutManager(new LinearLayoutManager(mRunReportActivity));
        final ArrayList<String> data = new ArrayList<>();
        data.add("http://www.yanxd.com/app/Tpl/new/images/carousel/2.jpg");
        data.add("http://www.yanxd.com/app/Tpl/new/images/carousel/1.jpg");
        data.add("http://www.yanxd.com/app/Tpl/new/images/carousel/12.jpg");
        data.add("http://www.yanxd.com/app/Tpl/new/images/carousel/11.jpg");

        mRunReportAdapter = new RunReportAdapter(data);
        recyclerView.setAdapter(mRunReportAdapter);
        mRunReportAdapter.setOnItemClickListener(this);
    }

    @OnClick(R.id.back_img)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        Logger.d("position:" + position);
        Intent intent = new Intent(RunReportActivity.this, HtmlLocalActivity.class);
        intent.putExtra("type", "html5");
        if (position == 0) {
            intent.putExtra("urlname", "2月");
            intent.putExtra("url", "http://www.yanxd.com/dataExpoed/2/data.html");
        } else if (position == 1) {
            intent.putExtra("urlname", "1月");
            intent.putExtra("url", "http://www.yanxd.com/dataExpoed/1/data.html");
        } else if (position == 2) {
            intent.putExtra("urlname", "12月");
            intent.putExtra("url", "http://www.yanxd.com/dataExpoed/12/data.html");
        } else if (position == 3) {
            intent.putExtra("urlname", "11月");
            intent.putExtra("url", "http://www.yanxd.com/dataExpoed/11/data.html");
        }
        startActivity(intent);
    }
}
